home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntinc20 / fcntl.h < prev    next >
C/C++ Source or Header  |  1992-05-15  |  3KB  |  128 lines

  1. /*
  2.  *    FCNTL.H
  3.  */
  4.  
  5. #ifndef    _FCNTL_H
  6. #define    _FCNTL_H
  7.  
  8. #ifndef _COMPILER_H
  9. #include <compiler.h>
  10. #endif
  11.  
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15.  
  16. #define    O_RDONLY    0x00        /* read only */
  17. #define    O_WRONLY    0x01        /* write only */
  18. #define    O_RDWR        0x02        /* read/write */
  19. #define O_ACCMODE    0x03        /* used to mask off file access mode */
  20.  
  21. /* file sharing modes (not POSIX) */
  22. #define O_COMPAT    0x00        /* old TOS compatibility mode */
  23. #define O_DENYRW    0x10        /* deny both reads and writes */
  24. #define O_DENYW        0x20
  25. #define O_DENYR        0x30
  26. #define O_DENYNONE    0x40        /* don't deny anything */
  27. #define O_SHMODE    0x70        /* mask for file sharing mode */
  28.  
  29. #define    O_NDELAY    0x100        /* Non-blocking I/O */
  30. #ifdef __MINT__
  31. # define O_SYNC        0x00        /* sync after writes (not implemented) */
  32. #endif
  33.  
  34. /* the following flags are not passed to the OS */
  35. #define    O_CREAT        0x200        /* create new file if needed */
  36. #define    O_TRUNC        0x400        /* make file 0 length */
  37. #define    O_EXCL        0x800        /* error if file exists */
  38. #define    O_APPEND    0x1000        /* position at EOF */
  39. #ifndef __MINT__
  40. # define O_PIPE        0x2000        /* serial pipe     */
  41. #endif
  42.  
  43. /*
  44.  * defines for the access() function
  45.  */
  46. #define    F_OK            0
  47. #define    X_OK            1
  48. #define    W_OK            2
  49. #define    R_OK            4
  50.  
  51. /*
  52.  * defines for fcntl()
  53.  */
  54. #define    F_DUPFD        0    /* Duplicate fildes */
  55. #define    F_GETFD        1    /* Get fildes flags */
  56. #define    F_SETFD        2    /* Set fildes flags */
  57. #define    F_GETFL        3    /* Get file flags */
  58. #define    F_SETFL        4    /* Set file flags */
  59.  
  60. #ifdef __MINT__
  61. #define F_GETLK        5    /* Get file lock */
  62. #define F_SETLK        6    /* Set file lock */
  63.  
  64. struct flock {
  65.     short l_type;
  66. #define F_RDLCK        O_RDONLY
  67. #define F_WRLCK        O_WRONLY
  68. #define F_UNLCK        3
  69.     short l_whence;
  70.     long l_start;
  71.     long l_len;
  72.     short l_pid;
  73. };
  74. #endif /* __MINT__ */
  75.  
  76.  
  77. #ifdef __MINT__
  78.  
  79. #define __NHANDLES 40
  80.  
  81. struct __open_file {
  82.     short    status;        /* whether or not it's a tty */
  83.     short    flags;        /* if a tty, its flags */
  84. };
  85.  
  86. #else
  87.  
  88. #define __NHANDLES    80
  89. struct __open_file {
  90.     unsigned short append:1;    /* 1 if O_APPEND set for this file */
  91.     unsigned short nodelay:1;    /* 1 if O_NDELAY set for this file */
  92.     unsigned short pipe:1;      /* 1 if O_PIPE set for this file */
  93.     unsigned short eclose:1;    /* 1 if close on exec is set for this file */
  94.     unsigned short status:2;    /* status FH_UNKNOWN | ISATTY | ISAFILE */
  95.     char       *filename;    /* filename of open file */
  96. };
  97.  
  98. #endif /* __MINT__ */
  99.  
  100. extern struct __open_file __open_stat[__NHANDLES];
  101.   /* NOTE: this array is indexed by (__OPEN_INDEX(fd)) */
  102.  
  103. /* smallest valid gemdos handle */
  104. /* note handle is only word (16 bit) negative, not long negative,
  105.    and since Fopen etc are declared as returning long in osbind.h
  106.    the sign-extension will not happen -- thanks ers
  107. */
  108. #ifdef __MSHORT__
  109. #define __SMALLEST_VALID_HANDLE (-3)
  110. #else
  111. #define __SMALLEST_VALID_HANDLE (0)
  112. #endif
  113.  
  114. #define __OPEN_INDEX(x)    (((short)(x)) + 3)
  115.  
  116. #define FH_UNKNOWN    0
  117. #define FH_ISATTY    1
  118. #define FH_ISAFILE    2
  119.  
  120.  
  121. __EXTERN int fcntl __PROTO((int f, int cmd, void *arg));
  122.  
  123. #ifdef __cplusplus
  124. }
  125. #endif
  126.  
  127. #endif /* _FCNTL_H */
  128.